<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}"/>
    <link rel="stylesheet" th:href="@{/static/layuiadmin/style/admin.css}" media="all"/>
    <script th:inline="javascript" type="text/javascript">
        var ctx = [[${#httpServletRequest.getContextPath()}]];
    </script>
</head>
<body class="layui-layout-body">
<div id="LAY_app">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <!-- 头部区域 -->
            <ul class="layui-nav layui-layout-left">
                <li class="layui-nav-item layadmin-flexible" lay-unselect><a
                        href="javascript:" layadmin-event="flexible" title="侧边伸缩"> <i
                        class="layui-icon layui-icon-shrink-right" id="LAY_app_flexible"></i>
                </a></li>
                <li class="layui-nav-item" lay-unselect><a href="javascript:"
                                                           layadmin-event="refresh" title="刷新"> <i
                        class="layui-icon layui-icon-refresh-3"></i>
                </a></li>
            </ul>
            <ul class="layui-nav layui-layout-right"
                lay-filter="layadmin-layout-right" style="padding-right:20px;">

                <!-- <li class="layui-nav-item" lay-unselect><a
                    lay-href="app/message/index.html" layadmin-event="message"
                    lay-text="消息中心"> <i class="layui-icon layui-icon-notice"></i>

                        如果有新消息，则显示小圆点 <span class="layui-badge-dot"></span>
                </a></li> -->
                <li class="layui-nav-item layui-hide-xs" lay-unselect><a
                        href="javascript:" layadmin-event="theme"> <i
                        class="layui-icon layui-icon-theme"></i>
                </a></li>
                <li class="layui-nav-item layui-hide-xs" lay-unselect><a
                        href="javascript:" layadmin-event="note"> <i
                        class="layui-icon layui-icon-note"></i>
                </a></li>
                <li class="layui-nav-item layui-hide-xs" lay-unselect><a
                        href="javascript:" layadmin-event="fullscreen"> <i
                        class="layui-icon layui-icon-screen-full"></i>
                </a></li>
                <li class="layui-nav-item" lay-unselect><a href="javascript:">
                    <cite>
                        <span th:text="${user.userName}"></span>
                    </cite>
                </a>
                    <dl class="layui-nav-child">
                        <!-- <dd>
                            <a lay-href="set/user/info.html">基本资料</a>
                        </dd> -->
                        <dd>
                            <a href="javascript:void(0)" onclick="changePassword()">修改密码</a>
                        </dd>
                        <hr>
                        <dd style="text-align: center;">
                            <a th:attr="href=@{/logout}">退出</a>
                        </dd>
                    </dl>
                </li>
            </ul>
        </div>

        <!-- 侧边菜单 -->
        <div class="layui-side layui-side-menu">
            <div class="layui-side-scroll">
                <div class="layui-logo" lay-href="home/console.html">
                    <span>后台管理</span>
                </div>
                <script type="text/html" template th:attr="lay-url=@{/menu/listAllPermission}"
                        lay-headers="{'x-auth-token': layui.data('layuiAdmin').token}"
                        lay-done="layui.element.render('nav', 'layadmin-system-side-menu');" id="TPL_layout">
                    <ul class="layui-nav layui-nav-tree" lay-shrink="all" id="LAY-system-side-menu"
                        lay-filter="layadmin-system-side-menu">
                        <li data-name="home" class="layui-nav-item layui-nav-itemed">
                            <a href="javascript:" lay-tips="主页" lay-direction="2">
                                <i class="layui-icon layui-icon-home"></i>
                                <cite>主页</cite>
                            </a>
                            <dl class="layui-nav-child">
                                <dd data-name="console">
                                    <a th:attr="lay-href=@{home/console.html}">
                                        <i class="layui-icon layui-icon-util"></i>
                                        <cite>控制台</cite>
                                    </a>
                                </dd>
                            </dl>
                        </li>
                        {{#
                        var path = layui.router().path
                        ,dataName = layui.setter.response.dataName;

                        layui.each(d[dataName], function(index, item){
                        var hasChildren = item.children && item.children.length > 0
                        ,classSelected = function(){
                        return '';
                        }
                        ,url = typeof item.url === 'string' ? item.url : item.title;
                        }}
                        <li data-name="{{ item.title || '' }}" data-jump="{{ item.url || '' }}"
                            class="layui-nav-item {{ classSelected() }}">
                            <a href="javascript:" {{ (hasChildren || !item.url) ? '' : 'lay-href="'+ctx+ url +'"' }}
                            lay-tips="{{ item.title }}"
                            lay-direction="2">
                            <i class="layui-icon {{ item.icon?item.icon:'layui-icon-home' }}"></i>
                            <cite>{{ item.title }}</cite>
                            </a>
                            {{# if(hasChildren){ }}
                            <dl class="layui-nav-child">
                                {{# layui.each(item.children, function(index2, item2){
                                var hasChildren2 = item2.children && item2.children.length > 0
                                ,classSelected2 = function(){

                                return '';
                                }
                                ,url2 = typeof item2.url === 'string'
                                ? item2.url
                                : [item.title, item2.title, ''].join('/');
                                }}
                                <dd data-name="{{ item2.title || '' }}" data-jump="{{ item2.url || '' }}"
                                    {{ classSelected2() ? (
                                'class="'+ classSelected2() +'"') : '' }}>
                                <a href="javascript:" {{ hasChildren2 ? '' : 'lay-href="'+ ctx+url2 +'"' }}>
                                <i class="layui-icon {{ item2.icon?item2.icon:'layui-icon-link' }}"></i>
                                <cite>{{ item2.title }}</cite>
                                </a>
                                {{# if(hasChildren2){ }}
                                <dl class="layui-nav-child">
                                    {{# layui.each(item2.children, function(index3, item3){
                                    var match = path[0] == item.name && path[1] == item2.name && path[2] == item3.name
                                    ,url3 = typeof item3.url === 'string'
                                    ? item3.url
                                    : [item.title, item2.title, item3.title].join('/')
                                    }}
                                    <dd data-name="{{ item3.title || '' }}" data-jump="{{ item3.url || '' }}"
                                        {{ match ?
                                    'class="layui-this"' : '' }}>
                                    <a href="javascript:" lay-href="{{ url3 }}">{{ item3.title }}</a>
                                    </dd>
                                    {{# }); }}
                                </dl>
                                {{# } }}
                                </dd>
                                {{# }); }}
                            </dl>
                            {{# } }}
                        </li>
                        {{# }); }}
                    </ul>
                </script>
            </div>
        </div>
        <!-- 页面标签 -->
        <div class="layadmin-pagetabs" id="LAY_app_tabs">
            <div class="layui-icon layadmin-tabs-control layui-icon-prev"
                 layadmin-event="leftPage"></div>
            <div class="layui-icon layadmin-tabs-control layui-icon-next"
                 layadmin-event="rightPage"></div>
            <div class="layui-icon layadmin-tabs-control layui-icon-down">
                <ul class="layui-nav layadmin-tabs-select"
                    lay-filter="layadmin-pagetabs-nav">
                    <li class="layui-nav-item" lay-unselect><a
                            href="javascript:"></a>
                        <dl class="layui-nav-child layui-anim-fadein">
                            <dd layadmin-event="closeThisTabs">
                                <a href="javascript:">关闭当前标签页</a>
                            </dd>
                            <dd layadmin-event="closeOtherTabs">
                                <a href="javascript:">关闭其它标签页</a>
                            </dd>
                            <dd layadmin-event="closeAllTabs">
                                <a href="javascript:">关闭全部标签页</a>
                            </dd>
                        </dl>
                    </li>
                </ul>
            </div>
            <div class="layui-tab" lay-unauto lay-allowClose="true"
                 lay-filter="layadmin-layout-tabs">
                <ul class="layui-tab-title" id="LAY_app_tabsheader">
                    <li lay-id="home/console.html" lay-attr="home/console.html"
                        class="layui-this"><i class="layui-icon layui-icon-home"></i></li>
                </ul>
            </div>
        </div>


        <!-- 主体内容 -->
        <div class="layui-body" id="LAY_app_body">
            <div class="layadmin-tabsbody-item layui-show">
                <iframe th:attr="src=@{/welcome}" frameborder="0" class="layadmin-iframe"></iframe>
            </div>
        </div>

        <!-- 辅助元素，一般用于移动设备下遮罩 -->
        <div class="layadmin-body-shade" layadmin-event="shade"></div>
    </div>
</div>
<script class="add_dlg" type="text/html">
    <div class="layui-card">
        <div class="layui-card-body">
            <form id="dataForm" class="layui-form" action=""
                  lay-filter="component-form-element">
                <input type="hidden" th:name="${user.userName}" id="id"/>
                <div class="layui-form-item">
                    <label class="layui-form-label">原密码：</label>
                    <div class="layui-input-block">
                        <input type="text" name="oldPassword" id="oldPassword"
                               lay-verify="required" placeholder="" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">新密码：</label>
                    <div class="layui-input-block">
                        <input type="text" name="password" id="password"
                               lay-verify="required" placeholder="" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">密码确认：</label>
                    <div class="layui-input-block">
                        <input type="text" name="newPassword2" id="newPassword2"
                               lay-verify="required" placeholder="" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
            </form>
        </div>
    </div>
</script>

<script th:src="@{/static/layui/layui.js}"></script>
<script>
    layui.config({
        base: ctx + '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: '/lib/index' //主入口模块
    }).use(['index', 'jquery'], function () {
        var $ = layui.jquery
        //初始化右侧菜单
    });

    function changePassword() {
        var $ = layui.jquery;
        layer.open({
            title: '密码修改',
            type: 1,
            content: $('.add_dlg').html(),
            btn: ['确定'],
            area: 'auto',
            yes: function (index, layero) {
                var data = $('#dataForm').serialize();
                $.post(ctx + '/user/changePassword', data, function (data) {
                    if (data.success) {
                        layer.close(index);
                        layer.msg("保存成功")
                    } else {
                        layer.msg(data.msg)
                    }
                });
            }
        });
    }
</script>
</body>
</html>